package com.myself.springboot.springboot_study.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.Map;
// 11111
@Component
// 通过在类上加此注解，可以直接读取yml文件中的对象数据2222233333
//@ConfigurationProperties(prefix = "")
@PropertySource(value = "classpath:person.properties")
public class Person {

    // 通过这种方式获取properties的值
//    @Value("${my.name}")
    private String name;
//    private String name;
    private Integer age;
    private Date time;
    private List<String> like;
    private Map<String,Integer> friends;
    private Pet pet;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public List<String> getLike() {
        return like;
    }

    public void setLike(List<String> like) {
        this.like = like;
    }

    public Map<String, Integer> getFriends() {
        return friends;
    }

    public void setFriends(Map<String, Integer> friends) {
        this.friends = friends;
    }

    public Pet getPet() {
        return pet;
    }

    public void setPet(Pet pet) {
        this.pet = pet;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", time=" + time +
                ", like=" + like +
                ", friends=" + friends +
                ", pet=" + pet +
                '}';
    }
}
